/*  ------------------------------------------------------------------------  */
/*  Paper        : Does Stakeholder Outrage Determine Executive Pay?          */
/*  Program      : a02-04-paycut_sensitivity.do                               */
/*  Description  : Paycut-performance sensitivity                             */
/*  ------------------------------------------------------------------------  */

use "$temp112/outragePanel.dta", clear

/*  ------------------------------------------------------------------------  */
//  Create return rank variable 

gen ret_rank = .
foreach num of numlist 2014/2020 {
	xtile ret_rank_`num' = exret_12m if fyear==`num', n(5)
	replace ret_rank = (ret_rank_`num') if fyear==`num' 
	drop ret_rank_`num'
}

foreach num of numlist 1/5 {
	summ exret_12m if ret_rank==`num'
}

//  Shock indicator
capture drop covid
gen covid = (fyear==2020) & mainsample==1

gen ret_rank_1 = (l1.ret_rank==1) if !missing(l1.ret_rank)
gen ret_rank_2 = (l1.ret_rank==2) if !missing(l1.ret_rank)
gen ret_rank_3 = (l1.ret_rank==3) if !missing(l1.ret_rank)
gen ret_rank_4 = (l1.ret_rank==4) if !missing(l1.ret_rank)


//  Polynomial on stock return 
gen polyLag = (l1.exret_12m^12)

foreach var of varlist ln_mcap btm leverage_mkt tangibility ret_std roa_std xrd_at payout_d {
	gen `var'Lag = l1.`var'
	local lab: var label `var'
	label var `var'Lag "`lab'"
}

gen covid_ret_rank_1 = (covid==1) & (l1.ret_rank==1) if !missing(l1.ret_rank)
gen covid_ret_rank_2 = (covid==1) & (l1.ret_rank==2) if !missing(l1.ret_rank)
gen covid_ret_rank_3 = (covid==1) & (l1.ret_rank==3) if !missing(l1.ret_rank)
gen covid_ret_rank_4 = (covid==1) & (l1.ret_rank==4) if !missing(l1.ret_rank)

/*  ------------------------------------------------------------------------  */
//  Regressions

global ct_1 i.sic2_ctrl ret_rank_* if mainsample==1 & inrange(fyear,2015,2021), vce(cluster firm_id)
global ct_2 ln_mcapLag btmLag leverage_mktLag tangibilityLag ret_stdLag roa_stdLag xrd_atLag payout_dLag

foreach num of numlist 1/4 {

local spec_1 dcut_all $ct_2 $ct_1
local spec_2 dcut_all covid $ct_2 i.sic2_ctrl if mainsample==1 & inrange(fyear,2015,2021), vce(cluster firm_id)
local spec_3 dcut_all covid covid_ret_rank_* $ct_2 $ct_1
local spec_4 dcut_all covid covid_ret_rank_* $ct_2 polyLag $ct_1

eststo r_`num': qui reg `spec_`num''

}

esttab r_* , order(covid ret_rank_* covid_ret_rank_*) drop(*sic2_ctrl )


/*  -|----------------------------------------------------------------------  */
/*  ||  ---    Program end: a02-04-paycut_sensitivity.do                      */
/*  -|  ---    Attila Balogh    --------------------------------------------  */